const Book = require('../models/book')

// 添加数据
async function addBook(BookObj) {
    // 验证 BookObj
    const ins = await Book.create(BookObj)
    return ins.toJSON()
}

// 删除数据
async function deleteBook(id) {
    await Book.destroy({ where: { id } })
}

// 修改数据
async function updateBook(id, BookObj) {
    await Book.update(BookObj, { where: { id } })
}

module.exports = { addBook, deleteBook, updateBook }